package com.kotlin.demo.类.接口的使用

import javax.sound.sampled.DataLine

/**
 * 1.接口中的成员和方法默认都是 public open
 * 2.接口没有主构造函数
 */
interface USB {
    var name: String
//      get() = (1..100).shuffled().first().toString()
    var version: String

    fun show()
}

class HDMI(override var name: String, override var version: String) : USB {

    override fun show() {
        "name: $name version : $version"
    }

}

open class DateLine1() : USB {

    override var name: String = "dateLine"
        get() {
            println("名称为 $field")
            return field
        }
        set(value) {
            field = value
            println("设置的值为$value")
        }

    override var version: String = ""
        get() {
            println("名称为:$field")
            return field
        }
        set(value) {
            field = value
            println("设置的值为$value")
        }

    override fun show() {
        "name: $name version : $version"
    }

}

fun main() {

    println(HDMI("HDMI", "3.2.1").show())
    val dateLine1 = DateLine1()
    dateLine1.name = ""
    println(dateLine1.show())





}